package com.freedom.admin.interfaces.facade;

import com.freedom.admin.api.feign.UserFeign;
import com.freedom.admin.application.service.query.UserQueryService;
import com.freedom.admin.api.pojo.dto.UserAuthDTO;
import com.freedom.common.core.result.CommonResult;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import lombok.RequiredArgsConstructor;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

@Api(tags = "「Feign调用」用户管理")
@RestController
@RequestMapping("/feign/user")
@RequiredArgsConstructor
public class UserFeignController implements UserFeign {

    private final UserQueryService userQueryService;

    @ApiOperation(value = "根据用户名获取认证信息", notes = "提供用于用户登录认证信息", hidden = true)
    @GetMapping("/find/{username}")
    @Override
    public CommonResult<UserAuthDTO> findUserByUsername(@PathVariable String username) {
        return CommonResult.success(userQueryService.findUserByUsername(username));
    }
}
